Technical Q&A

Java 07 - AppleScript for Java (17-May-1999)


Q: When I am scripting my Java application, I find it inconvenient to refer to objects as "object 1 of Frame 1". Is there any way to assign formal names to objects?

A: Yes. If you call java.awt.Component.setName() from your object in your Java source code, you can assign a more user-friendly name than the identifier generated by AppleScript for Java

public class
Salad extends Component
{
   public Salad()
   {
         ...
      this.setName( "Green Salad" );
         ...
   }
};


In this example, you would be able to communicate with your object in AppleScript by referring to it as Salad "Green Salad". This makes your "Green Salad" easier to distinguish from your "Caesar Salad" than would be possible if you used the default naming nomenclature, Salad 1, Salad 2, etc.


-- Michael Hopkins
Worldwide Developer Technical Support


Technical Q&As | Contents
Previous Question | Next Question

To contact us, please use the Contact Us page.